/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.mapperv2.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.mapperv2.CacheModel;
import org.taobao.ibatiside.model.mapperv2.FlushInterval;
import org.taobao.ibatiside.model.mapperv2.FlushOnExecute;
import org.taobao.ibatiside.model.mapperv2.Mapperv2Package;
import org.taobao.ibatiside.model.mapperv2.Property;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Cache Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getGroup <em>Group</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getFlushInterval <em>Flush Interval</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getFlushOnExecute <em>Flush On Execute</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getProperty <em>Property</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getId <em>Id</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getReadOnly <em>Read Only</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getSerialize <em>Serialize</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.mapperv2.impl.CacheModelImpl#getType <em>Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CacheModelImpl extends EObjectImpl implements CacheModel {
	/**
	 * The cached value of the '{@link #getGroup() <em>Group</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroup()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap group;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getReadOnly() <em>Read Only</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReadOnly()
	 * @generated
	 * @ordered
	 */
	protected static final Boolean READ_ONLY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getReadOnly() <em>Read Only</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReadOnly()
	 * @generated
	 * @ordered
	 */
	protected Boolean readOnly = READ_ONLY_EDEFAULT;

	/**
	 * The default value of the '{@link #getSerialize() <em>Serialize</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSerialize()
	 * @generated
	 * @ordered
	 */
	protected static final Boolean SERIALIZE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getSerialize() <em>Serialize</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSerialize()
	 * @generated
	 * @ordered
	 */
	protected Boolean serialize = SERIALIZE_EDEFAULT;

	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final Object TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected Object type = TYPE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CacheModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Mapperv2Package.Literals.CACHE_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getGroup() {
		if (group == null) {
			group = new BasicFeatureMap(this, Mapperv2Package.CACHE_MODEL__GROUP);
		}
		return group;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<FlushInterval> getFlushInterval() {
		return getGroup().list(Mapperv2Package.Literals.CACHE_MODEL__FLUSH_INTERVAL);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<FlushOnExecute> getFlushOnExecute() {
		return getGroup().list(Mapperv2Package.Literals.CACHE_MODEL__FLUSH_ON_EXECUTE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Property> getProperty() {
		return getGroup().list(Mapperv2Package.Literals.CACHE_MODEL__PROPERTY);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.CACHE_MODEL__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Boolean getReadOnly() {
		return readOnly;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReadOnly(Boolean newReadOnly) {
		Boolean oldReadOnly = readOnly;
		readOnly = newReadOnly;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.CACHE_MODEL__READ_ONLY, oldReadOnly, readOnly));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Boolean getSerialize() {
		return serialize;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSerialize(Boolean newSerialize) {
		Boolean oldSerialize = serialize;
		serialize = newSerialize;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.CACHE_MODEL__SERIALIZE, oldSerialize, serialize));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(Object newType) {
		Object oldType = type;
		type = newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Mapperv2Package.CACHE_MODEL__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Mapperv2Package.CACHE_MODEL__GROUP:
				return ((InternalEList<?>)getGroup()).basicRemove(otherEnd, msgs);
			case Mapperv2Package.CACHE_MODEL__FLUSH_INTERVAL:
				return ((InternalEList<?>)getFlushInterval()).basicRemove(otherEnd, msgs);
			case Mapperv2Package.CACHE_MODEL__FLUSH_ON_EXECUTE:
				return ((InternalEList<?>)getFlushOnExecute()).basicRemove(otherEnd, msgs);
			case Mapperv2Package.CACHE_MODEL__PROPERTY:
				return ((InternalEList<?>)getProperty()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Mapperv2Package.CACHE_MODEL__GROUP:
				if (coreType) return getGroup();
				return ((FeatureMap.Internal)getGroup()).getWrapper();
			case Mapperv2Package.CACHE_MODEL__FLUSH_INTERVAL:
				return getFlushInterval();
			case Mapperv2Package.CACHE_MODEL__FLUSH_ON_EXECUTE:
				return getFlushOnExecute();
			case Mapperv2Package.CACHE_MODEL__PROPERTY:
				return getProperty();
			case Mapperv2Package.CACHE_MODEL__ID:
				return getId();
			case Mapperv2Package.CACHE_MODEL__READ_ONLY:
				return getReadOnly();
			case Mapperv2Package.CACHE_MODEL__SERIALIZE:
				return getSerialize();
			case Mapperv2Package.CACHE_MODEL__TYPE:
				return getType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Mapperv2Package.CACHE_MODEL__GROUP:
				((FeatureMap.Internal)getGroup()).set(newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__FLUSH_INTERVAL:
				getFlushInterval().clear();
				getFlushInterval().addAll((Collection<? extends FlushInterval>)newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__FLUSH_ON_EXECUTE:
				getFlushOnExecute().clear();
				getFlushOnExecute().addAll((Collection<? extends FlushOnExecute>)newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__PROPERTY:
				getProperty().clear();
				getProperty().addAll((Collection<? extends Property>)newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__ID:
				setId((String)newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__READ_ONLY:
				setReadOnly((Boolean)newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__SERIALIZE:
				setSerialize((Boolean)newValue);
				return;
			case Mapperv2Package.CACHE_MODEL__TYPE:
				setType(newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Mapperv2Package.CACHE_MODEL__GROUP:
				getGroup().clear();
				return;
			case Mapperv2Package.CACHE_MODEL__FLUSH_INTERVAL:
				getFlushInterval().clear();
				return;
			case Mapperv2Package.CACHE_MODEL__FLUSH_ON_EXECUTE:
				getFlushOnExecute().clear();
				return;
			case Mapperv2Package.CACHE_MODEL__PROPERTY:
				getProperty().clear();
				return;
			case Mapperv2Package.CACHE_MODEL__ID:
				setId(ID_EDEFAULT);
				return;
			case Mapperv2Package.CACHE_MODEL__READ_ONLY:
				setReadOnly(READ_ONLY_EDEFAULT);
				return;
			case Mapperv2Package.CACHE_MODEL__SERIALIZE:
				setSerialize(SERIALIZE_EDEFAULT);
				return;
			case Mapperv2Package.CACHE_MODEL__TYPE:
				setType(TYPE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Mapperv2Package.CACHE_MODEL__GROUP:
				return group != null && !group.isEmpty();
			case Mapperv2Package.CACHE_MODEL__FLUSH_INTERVAL:
				return !getFlushInterval().isEmpty();
			case Mapperv2Package.CACHE_MODEL__FLUSH_ON_EXECUTE:
				return !getFlushOnExecute().isEmpty();
			case Mapperv2Package.CACHE_MODEL__PROPERTY:
				return !getProperty().isEmpty();
			case Mapperv2Package.CACHE_MODEL__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
			case Mapperv2Package.CACHE_MODEL__READ_ONLY:
				return READ_ONLY_EDEFAULT == null ? readOnly != null : !READ_ONLY_EDEFAULT.equals(readOnly);
			case Mapperv2Package.CACHE_MODEL__SERIALIZE:
				return SERIALIZE_EDEFAULT == null ? serialize != null : !SERIALIZE_EDEFAULT.equals(serialize);
			case Mapperv2Package.CACHE_MODEL__TYPE:
				return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (group: ");
		result.append(group);
		result.append(", id: ");
		result.append(id);
		result.append(", readOnly: ");
		result.append(readOnly);
		result.append(", serialize: ");
		result.append(serialize);
		result.append(", type: ");
		result.append(type);
		result.append(')');
		return result.toString();
	}

} //CacheModelImpl
